<template>
    <!--标签筛选选择器-->
    <a-select
            :placeholder="placeholder"
            v-model="value" showSearch showArrow allowClear
            @change="handleChange"
    >
        <a-select-option v-for="(item,index)  in groupOPT " :key="index"
                         :value="item.value">{{item.label}}
        </a-select-option>
    </a-select>
</template>
<script>
    import {groupDict} from '../../../util/internal.api';
    export default {
        props: ["code", "placeholder"],
        data() {
            return {
                groupOPT: [],
                value: undefined,
            }
        },
        methods: {
            //通知父组件修改选中的值
            handleChange(value) {
                this.$emit('groupSelectResult', value);
            },
        },
        created() {
            groupDict().then(res => this.groupOPT = res);
        },
        watch: {
            code(val) {
                this.value = val;
            }
        }
    };
</script>
